using System.Web.UI;

namespace BilSimser.SharePoint.Common.Controls
{
	public class OWSNumberField : OWSBase
	{
		#region construction

		/// <summary>
		/// Default constructor
		/// </summary>
		public OWSNumberField()
		{
		}

		#endregion

		#region Custom Properties

		/// <summary>
		/// Return the minimum value allowed
		/// </summary>
		public string Min
		{
			get { return "" + ViewState["Min"]; }
			set { ViewState["Min"] = value; }
		}

		/// <summary>
		/// Return the maximum value allowed
		/// </summary>
		public string Max
		{
			get { return "" + ViewState["Max"]; }
			set { ViewState["Max"] = value; }
		}

		#endregion

		#region overridden methods

		/// <summary>
		/// Renders the OWS Control
		/// </summary>
		/// <param name="wtr">writes out the text control information</param>
		protected override void Render (HtmlTextWriter wtr)
		{
			wtr.Write(
				"<SCRIPT>" +
					"fld=new NumberField(frm, '{0}', '{1}', '{2}'); " +
					"fld.fRequired = {3}; " +
					"fld.wMin = \"{4}\"; " +
					"fld.wMax = \"{5}\"; " +
					"fld.BuildUI(); " +
					"</SCRIPT>",
				UniqueID,
				Display,
				JavaScriptValue,
				Required.ToString().ToLower(),
				Min,
				Max
				);
		}

		#endregion
	}
}